var app =getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    page: 1,
    last_page: 1,
    httpUrl: "",
    amount: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.order_type == 'lawyer'){
      this.setData({httpUrl:"plugin.lawyer-platform.frontend.controllers.dividend.getLawyer"})
    }else{
      this.setData({httpUrl:"plugin.lawyer-platform.frontend.controllers.dividend.getLawyerFirm"})
    }
    this.getData()
  },
  getData() {
    app._postNetWork({
      url:app.getNetAddresss(this.data.httpUrl),
      success:(res)=>{
        if(res.data.result == 1){
          this.setData({
            list:res.data.data.list.data,
            amount:res.data.data.amount_total,
            last_page:res.data.data.list.last_page
          })
        }else{
          app.tips(res.data.msg)
        }
      }
    })
  },
  getMoreData(){
    let page = this.data.page+1;
    app._postNetWork({
      url:app.getNetAddresss(this.data.httpUrl),
      data:{page},
      success:(res)=>{
        if(res.data.result == 1){
          let list = this.data.list.concat(res.data.data.list.data);
          this.setData({
            page,
            list,
            last_page:res.data.data.list.last_page
          })
        }else{
          app.tips(res.data.msg)
        }
      }
    })
  },
  onReachBottom: function () {
    if(this.data.page>=this.data.last_page){
      return false;
    }else{
      this.getMoreData()
    }
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})